<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
    <div id="info"></div>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script>
        function make_base_auth(user, password) {
            var tok = user + ':' + password;
            var hash = btoa(tok);
            return"Basic " + hash; 
        }
        
        $(function(){
            alert(sessionStorage.getItem('token'));
            $.ajax({
                type:'get',
                url:"http://dzlua.top:5000/api/resource",
                contentType:false,
                dataType:'json',
                headers:{
                    "Authorization": make_base_auth(sessionStorage.getItem('token'), 'x')
                },
                success:function(data){
                    alert(JSON.stringify(data));
                    $('#info').html(data)
                },
                error:function(result){
                    alert(JSON.stringify(result))
                    // window.location.href="./login.html"
                }
            })
        })
    </script>
</body>
</html>